const express = require("express");
// 简历
const resume = require("../middleware/resume");
// 创建应用
const resumeApp = express();
// 获取个人信息
resumeApp.get("/getResume", [resume.getResumeInfo], (req, res) => {
    res.send({
        code: 200,
        data: req.resumeInfo
    });

});
// 获取个人信息
resumeApp.get("/getProject", [resume.getProject], (req, res) => {
    res.send(req.resumeInfo);
});
// 个人信息添加与编辑
resumeApp.post('/updatePersonalInfo', [resume.updatePersonalInfo], (req, res) => {
    if (req.data.affectedRows) {
        res.json({
            code: 200,
            msg: req.data.msg + '成功'
        });
    } else {
        res.json({
            code: 404,
            msg: req.data.msg + "失败",
        });
    }
});
// 社交链接修改与添加
resumeApp.post('/updateSocialLinks', [resume.updateSocialLinks], (req, res) => {
    if (req.data.affectedRows) {
        res.json({
            code: 200,
            msg: req.data.msg + '成功'
        });
    } else {
        res.json({
            code: 404,
            msg: req.data.msg + "失败",
        });
    }
});
// 技能链接修改与添加
resumeApp.post('/updateSkill', [resume.updateSkill], (req, res) => {
    if (req.data.affectedRows) {
        res.json({
            code: 200,
            msg: req.data.msg + '成功'
        });
    } else {
        res.json({
            code: 404,
            msg: req.data.msg + "失败",
        });
    }
});
// 项目修改与添加
resumeApp.post('/updateProject', [resume.updateProject], (req, res) => {
    if (req.data.affectedRows) {
        res.json({
            code: 200,
            msg: req.data.msg + '成功'
        });
    } else {
        res.json({
            code: 404,
            msg: req.data.msg + "失败",
        });
    }
});
// 工作信息修改与添加
resumeApp.post('/updateWork', [resume.updateWork], (req, res) => {
    if (req.data.affectedRows) {
        res.json({
            code: 200,
            msg: req.data.msg + '成功'
        });
    } else {
        res.json({
            code: 404,
            msg: req.data.msg + "失败",
        });
    }
});
// 学历信息修改与添加
resumeApp.post('/updateEducation', [resume.updateEducation], (req, res) => {
    if (req.data.affectedRows) {
        res.json({
            code: 200,
            msg: req.data.msg + '成功'
        });
    } else {
        res.json({
            code: 404,
            msg: req.data.msg + "失败",
        });
    }
});
resumeApp.get('/del', [resume.del], (req, res) => {
    if (req.affectedRows > 0) {
        res.json({
            code: 200,
            msg: '删除成功'
        })
    } else {
        res.json({
            code: 404,
            msg: '删除失败'
        })
    }
})
module.exports = resumeApp;
